package com.apollographql.apollo.http;

import com.apollographql.apollo.api.ExecutionContext;
import com.kt.Metadata;
import com.kt.jvm.functions.Function2;
import com.kt.jvm.internal.DefaultConstructorMarker;
import com.kt.jvm.internal.Intrinsics;
import okhttp3.Response;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0007\u0018\u0000 \f2\u00020\u0001:\u0001\fB\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\f\u0010\u000b\u001a\u00020\u0003*\u00020\u0003H\u0002R\u0018\u0010\u0005\u001a\u0006\u0012\u0002\b\u00030\u0006X\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\n¨\u0006\r"}, d2 = {"Lcom/apollographql/apollo/http/OkHttpExecutionContext;", "Lcom/apollographql/apollo/api/ExecutionContext$Element;", "response", "Lokhttp3/Response;", "(Lokhttp3/Response;)V", "key", "Lcom/apollographql/apollo/api/ExecutionContext$Key;", "getKey", "()Lcom/apollographql/apollo/api/ExecutionContext$Key;", "getResponse", "()Lokhttp3/Response;", "strip", "Key", "apollo-runtime"}, k = 1, mv = {1, 4, 0})
/* compiled from: OkHttpExecutionContext.kt */
public final class OkHttpExecutionContext implements ExecutionContext.Element {
    public static final Key KEY;
    public static final Key Key;
    private final ExecutionContext.Key<?> key = Key;
    private final Response response;

    public OkHttpExecutionContext(Response response2) {
        Intrinsics.checkParameterIsNotNull(response2, "response");
        this.response = strip(response2);
    }

    @Override // com.apollographql.apollo.api.ExecutionContext.Element, com.apollographql.apollo.api.ExecutionContext
    public <R> R fold(R r, Function2<? super R, ? super ExecutionContext.Element, ? extends R> function2) {
        Intrinsics.checkParameterIsNotNull(function2, "operation");
        return (R) ExecutionContext.Element.DefaultImpls.fold(this, r, function2);
    }

    @Override // com.apollographql.apollo.api.ExecutionContext.Element, com.apollographql.apollo.api.ExecutionContext
    public <E extends ExecutionContext.Element> E get(ExecutionContext.Key<E> key2) {
        Intrinsics.checkParameterIsNotNull(key2, "key");
        return (E) ExecutionContext.Element.DefaultImpls.get(this, key2);
    }

    @Override // com.apollographql.apollo.api.ExecutionContext.Element, com.apollographql.apollo.api.ExecutionContext
    public ExecutionContext minusKey(ExecutionContext.Key<?> key2) {
        Intrinsics.checkParameterIsNotNull(key2, "key");
        return ExecutionContext.Element.DefaultImpls.minusKey(this, key2);
    }

    @Override // com.apollographql.apollo.api.ExecutionContext
    public ExecutionContext plus(ExecutionContext context) {
        Intrinsics.checkParameterIsNotNull(context, "context");
        return ExecutionContext.Element.DefaultImpls.plus(this, context);
    }

    public final Response getResponse() {
        return this.response;
    }

    @Override // com.apollographql.apollo.api.ExecutionContext.Element
    public ExecutionContext.Key<?> getKey() {
        return this.key;
    }

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0003\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0003R\u0010\u0010\u0004\u001a\u00020\u00008\u0006X\u0004¢\u0006\u0002\n\u0000¨\u0006\u0005"}, d2 = {"Lcom/apollographql/apollo/http/OkHttpExecutionContext$Key;", "Lcom/apollographql/apollo/api/ExecutionContext$Key;", "Lcom/apollographql/apollo/http/OkHttpExecutionContext;", "()V", "KEY", "apollo-runtime"}, k = 1, mv = {1, 4, 0})
    /* compiled from: OkHttpExecutionContext.kt */
    public static final class Key implements ExecutionContext.Key<OkHttpExecutionContext> {
        private Key() {
        }

        public /* synthetic */ Key(DefaultConstructorMarker $constructor_marker) {
            this();
        }
    }

    static {
        Key key2 = new Key(null);
        Key = key2;
        KEY = key2;
    }

    private final Response strip(Response $this$strip) {
        Response.Builder builder = $this$strip.newBuilder();
        if ($this$strip.body() != null) {
            builder.body(null);
        }
        Response cacheResponse = $this$strip.cacheResponse();
        if (cacheResponse != null) {
            builder.cacheResponse(strip(cacheResponse));
        }
        Response networkResponse = $this$strip.networkResponse();
        if (networkResponse != null) {
            builder.networkResponse(strip(networkResponse));
        }
        Response build = builder.build();
        Intrinsics.checkExpressionValueIsNotNull(build, "builder.build()");
        return build;
    }
}
